# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS.  All contributing project authors may
# be found in the AUTHORS file in the root of the source tree.

import("../../build/webrtc.gni")

# Note this target is missing an implementation for the video capture.
# Targets must link with either 'video_capture' or
# 'video_capture_internal_impl' depending on whether they want to
# use the internal capturer.
source_set("video_capture_module") {
  sources = [
    "device_info_impl.cc",
    "device_info_impl.h",
    "include/video_capture.h",
    "include/video_capture_defines.h",
    "include/video_capture_factory.h",
    "video_capture_config.h",
    "video_capture_delay.h",
    "video_capture_factory.cc",
    "video_capture_impl.cc",
    "video_capture_impl.h",
  ]

  deps = [
    "../..:webrtc_common",
    "../../common_video",
    "../../system_wrappers",
    "../utility",
  ]

  configs += [ "../..:common_config" ]
  public_configs = [ "../..:common_inherited_config" ]

  if (is_clang) {
    # Suppress warnings from Chrome's Clang plugins.
    # See http://code.google.com/p/webrtc/issues/detail?id=163 for details.
    configs -= [ "//build/config/clang:find_bad_constructs" ]
  }
}

source_set("video_capture") {
  sources = [
    "external/device_info_external.cc",
    "external/video_capture_external.cc",
  ]

  deps = [
    ":video_capture_module",
    "../../system_wrappers",
  ]

  configs += [ "../..:common_config" ]
  public_configs = [ "../..:common_inherited_config" ]

  if (is_clang) {
    # Suppress warnings from Chrome's Clang plugins.
    # See http://code.google.com/p/webrtc/issues/detail?id=163 for details.
    configs -= [ "//build/config/clang:find_bad_constructs" ]
  }
}

if (!build_with_chromium) {
  config("video_capture_internal_impl_config") {
    if (is_ios) {
      libs = [
        "AVFoundation.framework",
        "CoreMedia.framework",
        "CoreVideo.framework",
      ]
    }
  }

  source_set("video_capture_internal_impl") {
    deps = [
      ":video_capture_module",
      "../../system_wrappers",
    ]

    if (is_linux) {
      sources = [
        "linux/device_info_linux.cc",
        "linux/device_info_linux.h",
        "linux/video_capture_linux.cc",
        "linux/video_capture_linux.h",
      ]
      deps += [ "../..:webrtc_common" ]
    }
    if (is_mac) {
      sources = [
        "mac/avfoundation/video_capture_avfoundation.h",
        "mac/avfoundation/video_capture_avfoundation.mm",
        "mac/avfoundation/video_capture_avfoundation_info.h",
        "mac/avfoundation/video_capture_avfoundation_info.mm",
        "mac/avfoundation/video_capture_avfoundation_info_objc.h",
        "mac/avfoundation/video_capture_avfoundation_info_objc.mm",
        "mac/avfoundation/video_capture_avfoundation_objc.h",
        "mac/avfoundation/video_capture_avfoundation_objc.mm",
        "mac/avfoundation/video_capture_avfoundation_utility.h",
        "mac/video_capture_mac.mm",
      ]

      libs = [
        "CoreVideo.framework",
      ]
    }
    if (is_win) {
      sources = [
        "windows/device_info_ds.cc",
        "windows/device_info_ds.h",
        "windows/device_info_mf.cc",
        "windows/device_info_mf.h",
        "windows/help_functions_ds.cc",
        "windows/help_functions_ds.h",
        "windows/sink_filter_ds.cc",
        "windows/sink_filter_ds.h",
        "windows/video_capture_ds.cc",
        "windows/video_capture_ds.h",
        "windows/video_capture_factory_windows.cc",
        "windows/video_capture_mf.cc",
        "windows/video_capture_mf.h",
      ]

      libs = [ "Strmiids.lib" ]

      deps += [ "//third_party/winsdk_samples"]
    }
    if (is_android) {
      sources = [
        "android/device_info_android.cc",
        "android/device_info_android.h",
        "android/video_capture_android.cc",
        "android/video_capture_android.h",
      ]

      deps += [
        "//third_party/icu:icuuc",
        "//third_party/jsoncpp",
      ]
    }
    if (is_ios) {
      sources = [
        "ios/device_info_ios.h",
        "ios/device_info_ios.mm",
        "ios/device_info_ios_objc.h",
        "ios/device_info_ios_objc.mm",
        "ios/rtc_video_capture_ios_objc.h",
        "ios/rtc_video_capture_ios_objc.mm",
        "ios/video_capture_ios.h",
        "ios/video_capture_ios.mm",
      ]

      cflags = [
        "-fobjc-arc",  # CLANG_ENABLE_OBJC_ARC = YES.
        # To avoid warnings for deprecated videoMinFrameDuration and
        # videoMaxFrameDuration properties in iOS 7.0.
        # See webrtc:3705 for more details.
        "-Wno-deprecated-declarations",
      ]
    }

    all_dependent_configs = [ ":video_capture_internal_impl_config" ]

    configs += [ "../..:common_config" ]
    public_configs = [ "../..:common_inherited_config" ]

    if (is_clang) {
      # Suppress warnings from Chrome's Clang plugins.
      # See http://code.google.com/p/webrtc/issues/detail?id=163 for details.
      configs -= [ "//build/config/clang:find_bad_constructs" ]
    }
  }
}
